package com.example.lxj.judicial.controller;

import java.util.List;
import java.util.Optional;

import com.example.lxj.base.annoation.Permission;
import com.example.lxj.base.controller.BaseController;
import com.example.lxj.base.entity.AjaxRes;
import com.example.lxj.base.entity.PageDTO;
import com.example.lxj.base.entity.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.lxj.judicial.entity.TbIdentificationAnalysis;
import com.example.lxj.judicial.service.ITbIdentificationAnalysisService;

import static com.github.pagehelper.page.PageMethod.startPage;

/**
 * 鉴定结果分析Controller
 *
 * @author lxj
 * @date 2024-10-24
 */
@RestController
@RequestMapping("/judicial/identification_analysis")
public class TbIdentificationAnalysisController extends BaseController {
    @Autowired
    private ITbIdentificationAnalysisService tbIdentificationAnalysisService;

    /**
     * 查询鉴定结果分析列表
     */
    @Permission(value = "judicial:identification_analysis:list")
    @GetMapping("/list")
    public TableDataInfo list(TbIdentificationAnalysis tbIdentificationAnalysis, PageDTO pageDTO) {
        startPage(Optional.ofNullable(pageDTO.getPageNo()).orElse(1), Optional.ofNullable(pageDTO.getPageSize()).orElse(10));
        List<TbIdentificationAnalysis> list = tbIdentificationAnalysisService.selectTbIdentificationAnalysisList(tbIdentificationAnalysis);
        return getDataTable(list);
    }

    /**
     * 获取鉴定结果分析详细信息
     */
    @Permission(value = "judicial:identification_analysis:query")
    @GetMapping(value = "/{id}")
    public AjaxRes getInfo(@PathVariable("id") Long id) {
        return success(tbIdentificationAnalysisService.selectTbIdentificationAnalysisById(id));
    }

    /**
     * 新增鉴定结果分析
     */
    @Permission(value = "judicial:identification_analysis:add")
    @PostMapping
    public AjaxRes add(@RequestBody TbIdentificationAnalysis tbIdentificationAnalysis) {
        return toAjax(tbIdentificationAnalysisService.insertTbIdentificationAnalysis(tbIdentificationAnalysis));
    }

    /**
     * 修改鉴定结果分析
     */
    @Permission(value = "judicial:identification_analysis:edit")
    @PutMapping
    public AjaxRes edit(@RequestBody TbIdentificationAnalysis tbIdentificationAnalysis) {
        return toAjax(tbIdentificationAnalysisService.updateTbIdentificationAnalysis(tbIdentificationAnalysis));
    }

    /**
     * 删除鉴定结果分析
     */
    @Permission(value = "judicial:identification_analysis:remove")
    @DeleteMapping("/{ids}")
    public AjaxRes remove(@PathVariable("ids") Long[] ids) {
        return toAjax(tbIdentificationAnalysisService.deleteTbIdentificationAnalysisByIds(ids));
    }
}
